package com.njcs.test;

import java.net.URL;
import java.util.List;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationFactory;

/**
 * @author Sam.Lee
 * @version Created：Nov 29, 2011 4:07:31 PM
 */
public class PropertiesXmlConfigurationExample {
	public static void main(String[] args) throws Exception {
		PropertiesXmlConfigurationExample example = new PropertiesXmlConfigurationExample();

		ConfigurationFactory factory = new ConfigurationFactory();
		String path = example.getClass().getResource("/").getPath();
		System.out.println(path);
		URL configURL = example.getClass().getResource(
				"/additional-xml-configuration.xml");
		factory.setConfigurationURL(configURL);

		Configuration config = factory.getConfiguration();

		List startCriteria = config.getList("start-criteria.criteria");
		System.out.println("Start Criteria: " + startCriteria);

		int horsepower = config.getInt("horsepower");
		System.out.println("Horsepower: " + horsepower);
		
		
		System.out.println("Speed:" + config.getFloat("speed"));
		System.out.println("Name:" + config.getString("name"));
	}
}
